package com.woniuxy.test_collection;

/**
 * description: TestGeneric <br>
 * date: 2022/2/2 9:22 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

/**
 * 测试泛型
 */

public class TestGeneric {
    public static void main(String[] args) {
        MyCollection<String> mc = new MyCollection<String>();
        mc.set("循环", 0);
        System.out.println(mc.get(0));

//        String[]s = new String[6];
//        s[0]="ss";
//        s[1]="a";
//        System.out.println(s[0]);

    }
}

class MyCollection<E> {
    Object[] objects = new Object[5];

    public void set(E e, int index) {
        objects[index] = e;
    }

    public E get(int index) {
        return (E) objects[index];
    }
}